package com.haitao.service.impl;

import com.fesine.dao.model.QueryResult;
import com.haitao.common.pojo.EUDataGridResult;
import com.haitao.common.pojo.HaitaoResult;
import com.haitao.po.ItemPo;
import com.haitao.service.ItemService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description: 商品服务实现类
 * @author: Fesine
 * @createTime:2017/5/14 20:05
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/5/14 20:05
 */
@Service
public class ItemServiceImpl extends BaseServiceImpl implements ItemService {


    @Override
    public ItemPo getItemById(long itemId) {
        ItemPo itemPo = new ItemPo();
        itemPo.setId(itemId);
        return daoService.selectOne(itemPo);
    }

    @Override
    public EUDataGridResult getItemList(ItemPo item, int page, int rows) {
        QueryResult<ItemPo> qr = daoService.selectQueryResult(item, page, rows);
        List<ItemPo> itemPoList = qr.getResultList();
        long total = qr.getTotalRecord();
        EUDataGridResult euDataGridResult = new EUDataGridResult();
        euDataGridResult.setTotal(total);
        euDataGridResult.setRows(itemPoList);
        return euDataGridResult;
    }

    @Override
    public HaitaoResult createItem(ItemPo item, String desc, String itemParam) throws Exception {
        return null;
    }
}
